package com.ruoyi.web.controller.modules;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.modules.domain.VehicleCompanyCertificate;
import com.ruoyi.modules.service.IVehicleCompanyCertificateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆单车核准证Controller
 * 
 * @author ssh
 * @date 2024-12-15
 */
@RestController
@RequestMapping("/modules/vehicleCompany/certificate")
public class VehicleCompanyCertificateController extends BaseController
{
    @Autowired
    private IVehicleCompanyCertificateService vehicleCompanyCertificateService;

    /**
     * 查询车辆单车核准证列表
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(VehicleCompanyCertificate vehicleCompanyCertificate)
    {
        startPage();
        List<VehicleCompanyCertificate> list = vehicleCompanyCertificateService.selectVehicleCompanyCertificateList(vehicleCompanyCertificate);
        return getDataTable(list);
    }

    /**
     * 导出车辆单车核准证列表
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:export')")
    @Log(title = "车辆单车核准证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VehicleCompanyCertificate vehicleCompanyCertificate)
    {
        List<VehicleCompanyCertificate> list = vehicleCompanyCertificateService.selectVehicleCompanyCertificateList(vehicleCompanyCertificate);
        ExcelUtil<VehicleCompanyCertificate> util = new ExcelUtil<VehicleCompanyCertificate>(VehicleCompanyCertificate.class);
        util.exportExcel(response, list, "车辆单车核准证数据");
    }

    /**
     * 获取车辆单车核准证详细信息
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(vehicleCompanyCertificateService.selectVehicleCompanyCertificateById(id));
    }

    /**
     * 新增车辆单车核准证
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:add')")
    @Log(title = "车辆单车核准证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VehicleCompanyCertificate vehicleCompanyCertificate)
    {
        return toAjax(vehicleCompanyCertificateService.insertVehicleCompanyCertificate(vehicleCompanyCertificate));
    }

    /**
     * 修改车辆单车核准证
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:edit')")
    @Log(title = "车辆单车核准证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleCompanyCertificate vehicleCompanyCertificate)
    {
        return toAjax(vehicleCompanyCertificateService.updateVehicleCompanyCertificate(vehicleCompanyCertificate));
    }

    /**
     * 删除车辆单车核准证
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:remove')")
    @Log(title = "车辆单车核准证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(vehicleCompanyCertificateService.deleteVehicleCompanyCertificateByIds(ids));
    }


    /**
     *  单车核准审核--->审核
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:add')")
    @Log(title = "单车核准审核", businessType = BusinessType.INSERT)
    @PostMapping("/singleCarApp")
    public AjaxResult singleCarApp(@RequestBody VehicleCompanyCertificate vehicleCompanyCertificate)
    {
        return toAjax(vehicleCompanyCertificateService.insertSingleCarApp(vehicleCompanyCertificate));
    }
}
